package com.dein.page.controller;

import org.omg.CORBA.Request;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by Feng on 2014-11-30.
 */
@Controller
@RequestMapping("page/")
public class PageController {
	@RequestMapping(value = "home", method = RequestMethod.GET)
	public String home(HttpServletRequest request) {
		String userName = (String) request.getSession()
				.getAttribute("userName");
		if (userName != null)
			return "player";
		else
			return "main";
	}

	@RequestMapping(value = "user", method = RequestMethod.GET)
	public String user(HttpServletRequest request) {
		String userName = (String) request.getSession()
				.getAttribute("userName");
		if (userName != null)
			return "users";
		else
			return "main";
	}

	@RequestMapping(value = "admin_index")
	public String admin_index() {
		return "admin_index";
	}

	@RequestMapping(value = "newBroadcast")
	public String newBroadcast() {
		return "admin_newBroadcast";
	}

	@RequestMapping(value = "admin_login", method = RequestMethod.GET)
	public String admin_index(HttpServletRequest request) {
		String adminName = (String) request.getSession().getAttribute(
				"adminName");
		if (adminName != null)
			return "admin_index";
		else
			return "admin_login";

	}
}
